<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="${pageContext.request.contextPath}/user/js/jquery-3.4.1.min.js"></script>
    <meta charset="UTF-8">
    <title>registere</title>
</head>
<body>
<center>
<form action="../user" method="post" >
    <input type="hidden" name="method" value="userRegistere">
    <table>
        <tr>
            <td colspan="2" style="text-align: center">
                <h2>注册&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="login.jsp" >登陆</a></h2>
            </td>

        </tr>
        <tr>
            <td>
                用户名：
            </td>
            <td>
                <input type="text" name="userName" onchange="findUserReChecking(this,this.value)">

            </td>
            <td>
                <span id="userName"></span>
            </td>
        </tr>
        <tr>
            <td>
                密码：
            </td>
            <td>
                <input type="text" name="userPassword">
            </td>
        </tr>

        <tr>
            <td colspan="2" style="text-align: center">

                <input type="submit" value="注册" >&nbsp;
            </td>
        </tr>
    </table>


</form>
</center>
</body>
<script>
    function findUserReChecking(obj,userName) {
        console.log(obj);
        var url = "../user?method=findUserReChecking&userName=" + userName;
        $.get(url,null,function (result) {
            console.log(result)
            if ("success" == result){
                $("#userName").text("用户名可用");
            }
            if ("false" == result){
                $("#userName").text("用户名不可用");
            }
        })
    }
</script>
</html>